package com.itools.core.service.impl;

import com.itools.core.base.CommonResult;
import com.itools.core.dto.fileRecord.FmsRecordDTO;
import com.itools.core.mapper.FmsFileRecordMapper;
import com.itools.core.result.FmsDetailRecordResult;
import com.itools.core.service.FmsRecordService;
import com.itools.core.utils.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * @description:
 * @author: XUCHANG
 * @create: 2021-03-28 15:51
 */
@Service
public class FmsRecordServiceImpl implements FmsRecordService {

	@Autowired
	private FmsFileRecordMapper fmsFileRecordMapper;

	/**
	 * 查询文件记录
	 * @param uniqueId 文件唯一id
	 * @return
	 */
	@Override
	public CommonResult<FmsDetailRecordResult> queryFssRecordByUniqueId(String uniqueId) {
		FmsRecordDTO queryParams = new FmsRecordDTO();
		queryParams.setUniqueId(uniqueId);
		List<FmsRecordDTO> recordDTOS = fmsFileRecordMapper.selectbySelective(queryParams);
		if (!CollectionUtils.isEmpty(recordDTOS)) {
			FmsRecordDTO record = recordDTOS.get(0);
			FmsDetailRecordResult result = new FmsDetailRecordResult();
			BeanUtils.copyProperties(record , result);
			return CommonResult.success(result);
		}
		return CommonResult.success(null);
	}

}
